// pages/my/edit-user-info/edit-user-info.js
const app = getApp()
const api = require('../../../utils/util')
import WxValidate from '../../../utils/WxValidate'
Page({
    // 页面分享
    onShareAppMessage () {},
    // 分享朋友圈
    onShareTimeline () {},

  /**
   * 页面的初始数据
   */
  data: {

    form: {
      logo: '',
      name: '',
      address: '',
      date: '',
      capital: '',
      category: '',
      pic: '',
      introduction: '',
      address_detail:''
    },

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let userinfo = app.globalData.userinfo;

    let that = this;

    if(!userinfo){
       wx.navigateTo({
         url: '/pages/login/login',
       })
    }

    let param = {
         ucode : app.globalData.userinfo.ucode,
    }
    let form = this.data.form
    api.get_enterprise(param).then(function(res){
         if(res.data.hasOwnProperty('id')){
            form.logo = app.globalData.siteUrl + res.data.logo;
            form.name = res.data.name;
            form.address = res.data.address;
            form.address_detail = res.data.address_detail;
            form.date = res.data.date;
            form.capital = res.data.capital;
            form.category = res.data.category;
            form.pic = app.globalData.siteUrl + res.data.pic;
            form.introduction = res.data.introduction;
         }
        console.log(form)
         that.setData({
           form
         })
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})